package com.ai.controller.acquisition;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.ai.common.constant.WseSectionConstants;
import com.ai.common.controller.BaseController;
import com.ai.common.model.Pagination;
import com.ai.model.edu.cms.info.dto.InfoDetailDTO;
import com.ai.model.edu.cms.info.vo.InfoDetailVO;
import com.ai.service.cms.info.InfoDetailService;

/**
 * 
 * Class Name		: AcquisitionController<br>
 * 
 * Description		: 资讯controller类<br>
 * 
 */
@Controller
public class AcquisitionController extends BaseController {
    
    @Resource private InfoDetailService         infoDetailService;

    /**
     * 资讯详情页
     * @param id
     * @return
     */
    @RequestMapping("/front/infoDetailPage/{id}")
    public ModelAndView infoPublishDetailPage(@PathVariable Long id){
    	ModelAndView mv = new ModelAndView();
		mv.setViewName("front/news");
		InfoDetailVO vo = infoDetailService.selectInfoDetailById(id);
		if(null != WseSectionConstants.sectionMap.get(vo.getLocChannelId().toString())) {
			vo.setLocChannelName(WseSectionConstants.sectionMap.get(vo.getLocChannelId().toString()));
		} else {
			vo.setLocChannelName("");
		}
		if(null != WseSectionConstants.sectionMap.get(vo.getLocThemeId().toString())) {
			vo.setLocThemeName(WseSectionConstants.sectionMap.get(vo.getLocThemeId().toString()));
		} else {
			vo.setLocThemeName("");
		}
		String videoUrl = vo.getVideoUrl();
		if (videoUrl!=null&&videoUrl!="") {
			Integer fromindex = videoUrl.lastIndexOf("/")+1;
			Integer toindex = videoUrl.indexOf(".html");
			vo.setVideoUrl(videoUrl.substring(fromindex, toindex));
		}
		mv.addObject(vo);
    	// 公告  start
		InfoDetailDTO dto = new InfoDetailDTO();
    	// 审核通过
    	dto.setQueryStatus(Byte.valueOf("3"));
    	//1级目录
    	dto.setLocChannelId(Long.valueOf("6"));
    	// 2级目录
    	dto.setLocThemeId(Long.valueOf("29"));
    	dto.setRows(5);
    	Pagination<InfoDetailVO> noticeList = infoDetailService.findInfoDetailPageByDto(dto,false);
    	mv.addObject("noticeList",noticeList.getRows());
    	// 公告  end
    	return mv;
    }
}
